package app.itgungnir.compose.wan.business.message

import androidx.lifecycle.ViewModel
import androidx.paging.PagingData
import app.itgungnir.compose.wan.utils.WanPagingResponse
import app.itgungnir.compose.wan.utils.pagingSourceWithoutCache
import app.itgungnir.compose.wan.utils.wanAndroidService
import app.itgungnir.compose.wan.utils.wanResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow

class MessageViewModel : ViewModel() {

    val unreadMessageReadState = MutableStateFlow(false)

    val unreadDataFlow: Flow<PagingData<Message>> = pagingSourceWithoutCache(firstPageIndex = 1, pageSize = 20) {
        wanAndroidService.getUnreadMessageList(pageNo = it).wanResponse<WanPagingResponse<Message>>()
    }

    val readDataFlow: Flow<PagingData<Message>> = pagingSourceWithoutCache(firstPageIndex = 1, pageSize = 20) {
        wanAndroidService.getReadMessageList(pageNo = it).wanResponse<WanPagingResponse<Message>>()
    }
}
